/*
 * BirthdayList.h
 *
 *  Created on: 22.04.2009
 *      Author: h3llfire
 */

#ifndef BIRTHDAYLIST_H_
#define BIRTHDAYLIST_H_


#include <wx/wx.h>
#include <wx/listctrl.h>
#include "../../core/Buddy.h"
#include "../../core/interfaces/iModule.h"
#include "../../core/Impp.h"
#include "../../core/events/ImppCommandEvent.h"
#include "../../core/events/BuddyChangedEvent.h"

namespace Impp {

#define STD_BIRTHDAYLIST_MODULE_NAME 			wxT("StdBirthdaylistModule")
#define STD_BIRTHDAYLIST_ACTION_SHOW 			wxT("showBirthdaylist")


int wxCALLBACK BirthdayListCompareFunction(long item1, long item2, long sortData);

class Birthdate{
private:
	int day;
	int month;
	int year;

public:
	Birthdate(int day, int month, int year);
	Birthdate(Buddy* buddy);
	int compare(const Birthdate & bd) const;
	wxString getAsString() const;
	int getDaysLeft(const wxDateTime & todayy) const;

};


class BirthdayList : public wxFrame {
private:
	enum{
		ID_UPDATE
	};

private:
	wxListCtrl* list;

public:
	BirthdayList(wxWindow* win);
	virtual ~BirthdayList();

	void onUpdate(wxCommandEvent & event);
	void onBuddyChanged(BuddyChangedEvent & event);

	int compareFunction(long item1, long item2);

private:
	DECLARE_EVENT_TABLE()
};


class StdBirthdayModule : public iModule{

	DECLARE_DYNAMIC_CLASS(StdBirthdayModule)

public:
	StdBirthdayModule(){};
	~StdBirthdayModule(){};

	void moduleInit();
	void moduleDestroy();

	void onImppCommand(ImppCommandEvent & event);
	static void wxCALLBACK addMainMenuItem(iMenu* menu, void* ptr);

};

}

#endif /* BIRTHDAYLIST_H_ */
